package com.cn.removewatermark.utils;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.HashMap;
import java.util.Map;

public class UrlUtils {

    /*
     * 将url携带的参数转化为map
     * */
    public static Map<String,String> urlParamToMap(String param){
        Map<String, String> paramMap = new HashMap<>();
        String[] split = param.split("&");
        for(String s:split){
            String[] keyValue=s.split("=");
            try {
                paramMap.put(URLDecoder.decode(keyValue[0],"UTF-8"),URLDecoder.decode(keyValue[1],"UTF-8"));
            }catch (UnsupportedEncodingException e){
                e.printStackTrace();
            }
        }
        return paramMap;
    }

}
